package com.sisyphus.mock.data.model;

public class BaseResponse<T> {

    public static final int FAIL_CODE = 203,
            SUCCESS_CODE              = 200,
            UNAUTHORIZED_CODE         = 401; // 登录失效


    public static <T> BaseResponse<T> fail(String message) {
        return BaseResponse.fail(FAIL_CODE, message);
    }

    public static <T> BaseResponse<T> fail(int code, String message) {
        return new BaseResponse<>(code, message, null);
    }

    public static <T> BaseResponse<T> success() {
        return BaseResponse.success("成功", null);
    }

    public static <T> BaseResponse<T> success(T data) {
        return BaseResponse.success("成功", data);
    }

    public static <T> BaseResponse<T> success(String message, T data) {
        return new BaseResponse<>(SUCCESS_CODE, message, data);
    }


    private int code;

    private String message;

    private T data;

    public BaseResponse(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

}
